﻿using System.Collections.Generic;
using XLua;
#if USE_UNI_LUA
using LuaAPI = UniLua.Lua;
using RealStatePtr = UniLua.ILuaState;
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
#else
using LuaAPI = XLua.LuaDLL.Lua;
using RealStatePtr = System.IntPtr;
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
#endif

namespace XLua.CSObjectWrap
{
    using Utils = XLua.Utils;

    public class UnityEngineAnimationCurveWrap
    {
        public static void __Register(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            System.Type type = typeof(UnityEngine.AnimationCurve);
            Utils.BeginObjectRegister(type, L, translator, 0, 7, 4, 3);

            Utils.RegisterFunc(L, Utils.METHOD_IDX, "Evaluate", _m_Evaluate);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "AddKey", _m_AddKey);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "MoveKey", _m_MoveKey);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "RemoveKey", _m_RemoveKey);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "SmoothTangents", _m_SmoothTangents);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "Equals", _m_Equals);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetHashCode", _m_GetHashCode);

            Utils.RegisterFunc(L, Utils.GETTER_IDX, "keys", _g_get_keys);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "length", _g_get_length);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "preWrapMode", _g_get_preWrapMode);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "postWrapMode", _g_get_postWrapMode);

            Utils.RegisterFunc(L, Utils.SETTER_IDX, "keys", _s_set_keys);
            Utils.RegisterFunc(L, Utils.SETTER_IDX, "preWrapMode", _s_set_preWrapMode);
            Utils.RegisterFunc(L, Utils.SETTER_IDX, "postWrapMode", _s_set_postWrapMode);

            Utils.EndObjectRegister(type, L, translator, __CSIndexer, null, null, null, null);

            Utils.BeginClassRegister(type, L, __CreateInstance, 4, 0, 0);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Constant", _m_Constant_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Linear", _m_Linear_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "EaseInOut", _m_EaseInOut_xlua_st_);

            Utils.EndClassRegister(type, L, translator);
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __CreateInstance(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (
                    LuaAPI.lua_gettop(L) >= 1
                    && (
                        LuaTypes.LUA_TNONE == LuaAPI.lua_type(L, 2)
                        || translator.Assignable<UnityEngine.Keyframe>(L, 2)
                    )
                )
                {
                    UnityEngine.Keyframe[] _keys = translator.GetParams<UnityEngine.Keyframe>(L, 2);

                    var gen_ret = new UnityEngine.AnimationCurve(_keys);
                    translator.Push(L, gen_ret);

                    return 1;
                }
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    var gen_ret = new UnityEngine.AnimationCurve();
                    translator.Push(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(
                L,
                "invalid arguments to UnityEngine.AnimationCurve constructor!"
            );
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        public static int __CSIndexer(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.AnimationCurve>(L, 1)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                )
                {
                    UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                        translator.FastGetCSObj(L, 1);
                    int index = LuaAPI.xlua_tointeger(L, 2);
                    LuaAPI.lua_pushboolean(L, true);
                    translator.Push(L, gen_to_be_invoked[index]);
                    return 2;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            LuaAPI.lua_pushboolean(L, false);
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Evaluate(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                {
                    float _time = (float)LuaAPI.lua_tonumber(L, 2);

                    var gen_ret = gen_to_be_invoked.Evaluate(_time);
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_AddKey(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                int gen_param_count = LuaAPI.lua_gettop(L);

                if (
                    gen_param_count == 3
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)
                )
                {
                    float _time = (float)LuaAPI.lua_tonumber(L, 2);
                    float _value = (float)LuaAPI.lua_tonumber(L, 3);

                    var gen_ret = gen_to_be_invoked.AddKey(_time, _value);
                    LuaAPI.xlua_pushinteger(L, gen_ret);

                    return 1;
                }
                if (gen_param_count == 2 && translator.Assignable<UnityEngine.Keyframe>(L, 2))
                {
                    UnityEngine.Keyframe _key;
                    translator.Get(L, 2, out _key);

                    var gen_ret = gen_to_be_invoked.AddKey(_key);
                    LuaAPI.xlua_pushinteger(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AnimationCurve.AddKey!");
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_MoveKey(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                {
                    int _index = LuaAPI.xlua_tointeger(L, 2);
                    UnityEngine.Keyframe _key;
                    translator.Get(L, 3, out _key);

                    var gen_ret = gen_to_be_invoked.MoveKey(_index, _key);
                    LuaAPI.xlua_pushinteger(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_RemoveKey(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                {
                    int _index = LuaAPI.xlua_tointeger(L, 2);

                    gen_to_be_invoked.RemoveKey(_index);

                    return 0;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_SmoothTangents(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                {
                    int _index = LuaAPI.xlua_tointeger(L, 2);
                    float _weight = (float)LuaAPI.lua_tonumber(L, 3);

                    gen_to_be_invoked.SmoothTangents(_index, _weight);

                    return 0;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Constant_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    float _timeStart = (float)LuaAPI.lua_tonumber(L, 1);
                    float _timeEnd = (float)LuaAPI.lua_tonumber(L, 2);
                    float _value = (float)LuaAPI.lua_tonumber(L, 3);

                    var gen_ret = UnityEngine.AnimationCurve.Constant(_timeStart, _timeEnd, _value);
                    translator.Push(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Linear_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    float _timeStart = (float)LuaAPI.lua_tonumber(L, 1);
                    float _valueStart = (float)LuaAPI.lua_tonumber(L, 2);
                    float _timeEnd = (float)LuaAPI.lua_tonumber(L, 3);
                    float _valueEnd = (float)LuaAPI.lua_tonumber(L, 4);

                    var gen_ret = UnityEngine.AnimationCurve.Linear(
                        _timeStart,
                        _valueStart,
                        _timeEnd,
                        _valueEnd
                    );
                    translator.Push(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_EaseInOut_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    float _timeStart = (float)LuaAPI.lua_tonumber(L, 1);
                    float _valueStart = (float)LuaAPI.lua_tonumber(L, 2);
                    float _timeEnd = (float)LuaAPI.lua_tonumber(L, 3);
                    float _valueEnd = (float)LuaAPI.lua_tonumber(L, 4);

                    var gen_ret = UnityEngine.AnimationCurve.EaseInOut(
                        _timeStart,
                        _valueStart,
                        _timeEnd,
                        _valueEnd
                    );
                    translator.Push(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Equals(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable<object>(L, 2))
                {
                    object _o = translator.GetObject(L, 2, typeof(object));

                    var gen_ret = gen_to_be_invoked.Equals(_o);
                    LuaAPI.lua_pushboolean(L, gen_ret);

                    return 1;
                }
                if (gen_param_count == 2 && translator.Assignable<UnityEngine.AnimationCurve>(L, 2))
                {
                    UnityEngine.AnimationCurve _other = (UnityEngine.AnimationCurve)
                        translator.GetObject(L, 2, typeof(UnityEngine.AnimationCurve));

                    var gen_ret = gen_to_be_invoked.Equals(_other);
                    LuaAPI.lua_pushboolean(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AnimationCurve.Equals!");
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_GetHashCode(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);

                {
                    var gen_ret = gen_to_be_invoked.GetHashCode();
                    LuaAPI.xlua_pushinteger(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_keys(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.keys);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_length(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.length);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_preWrapMode(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.preWrapMode);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_postWrapMode(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.postWrapMode);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_keys(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.keys = (UnityEngine.Keyframe[])
                    translator.GetObject(L, 2, typeof(UnityEngine.Keyframe[]));
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_preWrapMode(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                UnityEngine.WrapMode gen_value;
                translator.Get(L, 2, out gen_value);
                gen_to_be_invoked.preWrapMode = gen_value;
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_postWrapMode(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.AnimationCurve gen_to_be_invoked = (UnityEngine.AnimationCurve)
                    translator.FastGetCSObj(L, 1);
                UnityEngine.WrapMode gen_value;
                translator.Get(L, 2, out gen_value);
                gen_to_be_invoked.postWrapMode = gen_value;
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }
    }
}
